package io.renren.modules.business.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.renren.modules.business.entity.EDepartmentEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;
import io.renren.modules.business.dao.EDepartmentDao;
import io.renren.modules.business.service.EDepartmentService;


@Service("eDepartmentService")
public class EDepartmentServiceImpl extends ServiceImpl<EDepartmentDao, EDepartmentEntity> implements EDepartmentService {

    @Autowired
    private EDepartmentDao eDepartmentDao;

    @Override
    public IPage<Map<String, Object>> queryDepartment(Integer pageNum, Integer pageSize, Long departmentId, String departmentName) {
        Page page = new Page<>(pageNum, pageSize);
        return eDepartmentDao.queryDepartment(page, departmentId, departmentName);
    }

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<EDepartmentEntity> page = this.page(
                new Query<EDepartmentEntity>().getPage(params),
                new QueryWrapper<EDepartmentEntity>()
        );

        return new PageUtils(page);
    }

}